﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SundStudent.ControlLayer;
using SundStudent.ModelLayer;

namespace SundStudent.GUILayer
{
    public partial class StudentForm : Form
    {
        private List<Modul> modulList;
        private List<Tema> temaList;
        private List<Patient> patientList;
        private List<Underviser> underviserList;
        private List<Stue> stueList;
        private List<Seng> sengList;
        private Modul valgtModul;
        private Stue valgtStue;
        private List<Lektion> listLektion;
        private List<LektionsPatient> listLektionsPatient;

        public StudentForm()
        {
            InitializeComponent();
            
        }

       
        
       

        

        private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
        {
            String dato = dateTimePicker1.Text.ToString();
            DateTime dato1 = new DateTime();
            dato1 = DateTime.Parse(dato);
            Console.WriteLine("valgt dato " + dato);  
            //Find hvilke moduler er paa den valgte dag
            StuderendeControler ctrlStud = new StuderendeControler();
            listLektion = ctrlStud.hentLektioner(dato1);
            listBox1.Items.Clear();
            listBox2.Items.Clear();
            listBox3.Items.Clear();
            listBox4.Items.Clear();
            listBox5.Items.Clear();
            listLektionsPatient = new List<LektionsPatient>();
            if (listLektion != null)
            {
                PatientControler ctrlPatient = new PatientControler();
                foreach (Lektion lekObj in listLektion)
                {
                    LektionsPatient lekpatientObj = ctrlPatient.hentPatientTilLektion(lekObj.Nr);
                    if (lekpatientObj != null)
                    {
                        listLektionsPatient.Add(lekpatientObj);
                        listBox2.Items.Add(lekObj.ModulObj.Modulnr);
                        listBox3.Items.Add(lekObj.TemaObj.Navn);
                        listBox1.Items.Add(lekpatientObj.Navn);
                        listBox4.Items.Add(lekObj.StueObj.Stuenr);
                        listBox5.Items.Add(lekpatientObj.Seng.Sengnr);
                    }

                }
            }

        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int index = listBox1.SelectedIndex;
          
            LektionsPatient patientObj = listLektionsPatient.ElementAt(index);
            if (patientObj != null)
            {
                PationeGenerelForm patientGUI = new PationeGenerelForm(patientObj);
                patientGUI.Show();
            }

        }

       
    }
}
